<?php


namespace audit\server;


use app\common\model\School;
use app\traits\Api;

class SiChuan extends Area
{

    function getAuditState($data)
    {
        if ($data['is_hk']==0){
            //非在校生？
            if ($data['is_school'] ==1){
                //是否研究生？
                if (!in_array($data['education'],[6,7])){
                    //全日制
                    if ($data['is_full_time']==0){
                        return Api::error('审核不通过：未到三年或非毕业学年');
                    }else{
                        //学制3年以上
                        if ($data['study_yeah']<3){
                            return Api::error('审核不通过：未达三年学制');
                        }
                        //专科二年级以上
                        if (is_array($data['education'],[1,2,3,4])){
                            $in_school = date('Ymd')-$data['entrance'];
                            if ($in_school<2){
                                return Api::error('审核不通过：未达二年级');
                            }
                        }
                        //本科3年级以上
                        if (is_array($data['education'],[5])){
                            $in_school = date('Ymd')-$data['entrance'];
                            if ($in_school<3){
                                return Api::error('审核不通过：未达三年级');
                            }
                        }


                    }
                }
            }else{
                //学校是否在报考地区
                $school= School::where('school_name',$data['school'])->field('province,city')->find();
                $school_area = $school->province.' '.$school->city;
                if ($school_area!=$data['exam_address']){
                    //不是本市户籍的
                    if ($data['census']!=$data['exam_address']){
                        return Api::error('审核不通过：非本市考生');
                    }
                    return Api::error('审核不通过：非本市就读的非全日制考生');
                }
            }
        }else{
            //学校是否在报考地区
            $school= School::where('school_name',$data['school'])->field('province,city')->find();
            $school_area = $school->province.' '.$school->city;
            if ($school_area!=$data['exam_address']){
                //不是本市户籍的
                if ($data['census']!=$data['exam_address']){
                    return Api::error('审核不通过：非本市考生');
                }
                return Api::error('审核不通过：非本市就读的非全日制考生');
            }
        }
        return Api::success('恭喜！您的信息成功通过验证');
    }
}